# -*- coding: utf-8 -*- 
# 作者:飞虎
# 开发时间:2022/5/20 14:48
from PyQt5.Qt import *


class Window(QWidget):
	def __init__(self):
		super().__init__()
		self.setWindowTitle('QGridLayout学习')
		self.resize(500, 500)
		self.setup_ui()

	def setup_ui(self):
		gl = QGridLayout()

		self.setLayout(gl)

		label1 = QLabel('标签1')
		label1.setStyleSheet('background-color:cyan')
		label2 = QLabel('标签2')
		label2.setStyleSheet('background-color:yellow')
		label3 = QLabel('标签3')
		label3.setStyleSheet('background-color:red')
		# label4 = QLabel('标签4')
		# label4.setStyleSheet('background-color:orange')
		gl.addWidget(label1, 0, 0)
		gl.addWidget(label2, 0, 1)
		gl.addWidget(label3, 1, 0,3,2)

		label5 = QLabel('标签5')
		label5.setStyleSheet('background-color:pink;')
		label6 = QLabel('标签6')
		label6.setStyleSheet('background-color:blue;')
		label7 = QLabel('标签7')
		label7.setStyleSheet('background-color:cyan;')
		#
		# v_layout = QVBoxLayout()
		v_layout = QVBoxLayout()
		# v_layout.setDirection(QBoxLayout.RightToLeft)
		v_layout.addWidget(label5)
		v_layout.addWidget(label6)
		v_layout.addWidget(label7)

		gl.addLayout(v_layout,4,0,1,3)

		# print(gl.getItemPosition(1))
		# print(gl.itemAtPosition(0,1).widget().text())

		# gl.setColumnMinimumWidth(0,100)
		# gl.setRowMinimumHeight(0,100)
		# gl.setColumnStretch(0,2)
		# gl.setColumnStretch(1,1)
		# gl.setRowStretch(4,1)

		print(gl.spacing())
		print(gl.horizontalSpacing())
		print(gl.verticalSpacing())

		gl.setVerticalSpacing(60)
		gl.setHorizontalSpacing(60)

		gl.setOriginCorner(Qt.BottomLeftCorner)

		print(gl.rowCount())
		print(gl.columnCount())
		



if __name__ == '__main__':
	import sys

	app = QApplication(sys.argv)
	window = Window()
	gl = window.layout()
	window.show()

	print(gl.cellRect(0,1))

	sys.exit(app.exec_())
